<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>档案管理</title>
    <link rel="stylesheet" href="assets/lib/iview/iview.css">
    <link rel="stylesheet" href="assets/css/login.css">
    <script src="assets/lib/iview/vue.min.js"></script>
    <script src="assets/lib/iview/iview.js"></script>
    <script src="assets/js/cookie.js"></script>
	<script>
	(function(){
	try{
		var gui = require('nw.gui');
		var win = gui.Window.get();
		win.maximize();
	}catch(err){
		console.log('not nw.js');
	}
	})();
	</script>
</head>

<body>
    <div id="main" class="app-main">
        <div class="login" @keydown.enter="handleSubmit">
            <div class="login-con">
                <card :bordered="false">
                    <p slot="title">
                        <Icon type="log-in"></Icon>
                        欢迎登录
                    </p>
                    <div class="form-con">
                        <i-form ref="loginForm" :model="form" :rules="rules">
                            <form-item prop="userName">
                                <i-input v-model="form.userName" placeholder="请输入用户名">
                                    <span slot="prepend">
                                        <Icon :size="16" type="person"></Icon>
                                    </span>
                                </i-input>
                            </form-item>
                            <form-item prop="password">
                                <i-input type="password" v-model="form.password" placeholder="请输入密码">
                                    <span slot="prepend">
                                        <Icon :size="14" type="locked"></Icon>
                                    </span>
                                </i-input>
                            </form-item>
                            <form-item>
                                <i-button @click="handleSubmit" type="primary" long>登录</i-button>
                            </form-item>
                        </i-form>
                        <p class="login-tip">2018 &copy; 路寨基督教堂</p>
                    </div>
                </card>
            </div>
        </div>
    </div>
    <script>
        var app = new Vue({
            el: "#main",
            data: {
                form: {
                    userName: '',
                    password: ''
                },
                rules: {
                    userName: [
                        { required: true, message: '账号不能为空', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '密码不能为空', trigger: 'blur' }
                    ]
                }
            },
            methods: {
                handleSubmit: function () {
                    this.$refs.loginForm.validate((valid) => {
                        if (valid) {
                            if (this.form.userName === 'admin' && this.form.password === 'admin888') {
                                Cookies.set('access', 'ok');
                                top.location.href='index.html';
                            } else {
                                this.$Message.error('用户名或密码错误');
                            }
                        }
                    });
                }
            }
        });
    </script>
</body>

</html>